/**
 * Project  : Looker
 * Package  : net.freestu.looker.common
 * File     : NewsMeta.java
 * Author   : solosky < solosky772@qq.com >
 * Date     : Jul 29, 2009
 * Modified : Jul 29, 2009
 * License  : Apache License 2.0 
 */
package net.freestu.looker.common;

import java.util.ArrayList;

import org.apache.commons.lang.builder.ToStringBuilder;

import net.freestu.looker.util.HashUtils;

/**
 *  新闻元信息
 *  仅保存了新闻的一些基本信息，便于检查新闻删除和新增
 * @author  solosky
 * @version v1.0
 */
public class NewsMeta
{

	/**
	 * 新闻编号
	 */
	protected String hash;
	
	/**
	 * 新闻地址
	 */
	protected String url;
	
	/**
	 * 新闻正文签名
	 * 用于判断新闻是否更新了
	 */
	protected String signature;
	
	/**
	 * 栏目对象
	 */
	private Category category;
	
	/**
	 * 新闻附件列表
	 */
	protected ArrayList<String> mediaHashList;



	public String getHash()
    {
    	return hash;
    }

	public void setHash(String hash)
    {
    	this.hash = hash;
    }

	public String getUrl()
    {
    	return url;
    }

	public void setUrl(String url)
    {
    	this.url = url;
    	this.hash = HashUtils.longHash(url);
    }


	public String getSignature()
    {
    	return signature;
    }

	public void setSignature(String signature)
    {
    	this.signature = signature;
    }

	public ArrayList<String> getMediaHashList()
    {
    	return mediaHashList;
    }

	public void setMediaHashList(ArrayList<String> mediaHashList)
    {
    	this.mediaHashList = mediaHashList;
    }
	
	public Category getCategory()
    {
    	return category;
    }

	public void setCategory(Category category)
    {
    	this.category = category;
    }
	
	/**
	 * 转化为NewsEntity对象
	 */
	public NewsEntity toNewsEntity()
	{
		NewsEntity entity = new NewsEntity();
		entity.setUrl(this.url);
		entity.setCategory(category);
		
		return entity;
	}
	
	/**
	 * ToString
	 */
	public String toString()
	{
		return new ToStringBuilder(this)
		.append("url",url)
		//.append("category",category)
		.toString();
	}
	
	
}
